<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
    <meta charset="UTF-8">
    <title>安排开题交叉评阅</title>
    <link th:href="@{/css/ugly-table.css}" href="../static/css/ugly-table.css" rel="stylesheet">
    <link th:href="@{/css/bootstrap.min.css}" href="../static/css/bootstrap.min.css" rel="stylesheet">
    <link th:href="@{/css/flat-ui.css}" href="../static/css/flat-ui.css" rel="stylesheet">
    <link th:href="@{/css/signin.css}" href="../static/css/signin.css" rel="stylesheet">
    <link th:href="@{/css/jquery-ui.min.css}" href="../static/css/jquery-ui.min.css" rel="stylesheet">
</head>

<body th:inline="text">

<style>
body {
min-height: 2000px;
padding-top: 70px;
}
.pageContent{
width: auto;
height: 800px;
}
</style>
<!--顶部导航栏-->
<div th:include="a-head :: a-head"></div>
<!--中间主体-->
<div class="pageContainer">
<!--正文内容-->
<div class="pageContent">

    <p sec:authentication="name"></p>

    <div class="panel panel-default">
        <div class="panel-heading">
            <!-- 增删改查 -->
            <div class="form-inline">
                <form th:action="@{/admin/seltaskname}" action="/admin/seltaskname" method="post">
                    <label>课题名称：</label>
                    <select id="tasknameSelection" data-toggle="select" class="form-control" name="tasknameSelection" >
                        <div >
                            <option th:each="task,list:${tasklist}" th:value="${task.taskname}"
                                    th:selected="${tasknameSelectionValue}" th:text="${task.taskname}"></option>
                        </div>
                    </select>
                    <input id="ftype" type="hidden" value="开题报告" name="ftype"/>
                    <button type="submit"  class="btn btn-primary" onclick="searchtaskname(obj)">查询</button>
                </form>
                <form th:action="@{/admin/selstate}" action="/admin/selstate" method="post">
                    <label>评阅状态：</label>
                    <select id="stateSelection" name="stateSelection"class="form-control">
                        <option value="待评阅"th:selected="${stateSelectionValue2}">待评阅</option>
                        <option value="已通过"th:selected="${stateSelectionValue3}">已通过</option>
                        <option value="未通过"th:selected="${stateSelectionValue4}">未通过</option>
                    </select>
                    <input id="ftype1" type="hidden" value="开题报告" name="ftype1"/>
                    <button type="submit" class="btn btn-primary" >查询</button>
                </form>
            </div>
        </div>
        <div class="panel-body">
            <div class="form-inline">
                <!-- 新增模态框 -->
                <button class="btn btn-primary" data-toggle="modal" data-target="#myModal">新增</button>
                <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal"
                                    aria-hidden="true">×
                                </button>
                                <h7 class="modal-title" id="myModalLabel">新增记录</h7>
                            </div>
                            <div class="modal-body">
                                <form th:action="@{/admin/addrecord}" action="/admin/addrecord"  method="post">
                                    <div class="form-group form-inline">
                                        <label for="txt_taskname">课题名称</label>
                                        <input type="text" name="txt_taskname" class="form-control" id="txt_taskname" placeholder="课题名称">
                                    </div>
                                    <div class="form-group form-inline">
                                        <label for="txt_stuname">学生姓名</label>
                                        <input type="text" name="txt_stuname" class="form-control" id="txt_stuname" placeholder="学生姓名">
                                    </div>
                                    <div class="form-group form-inline">
                                        <label for="txt_tutorname">导师姓名</label>
                                        <input type="text" name="txt_tutorname" class="form-control" id="txt_tutorname" placeholder="导师姓名">
                                    </div>
                                    <div class="form-group form-inline">
                                        <label for="txt_tutorid">导师id</label>
                                        <input type="text" name="txt_tutorid" class="form-control" id="txt_tutorid" placeholder="导师id">
                                    </div>
                                    <div class="form-group form-inline">
                                        <input type="text" name="txt_filename" class="form-control" id="txt_filename" placeholder="文件命名">
                                        <button type="button" id="upload_btn" class="btn btn-primary" >文件上传</button>
                                    </div>
                                    <button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>
                                    <button type="submit" class="btn btn-primary" >提交更改</button>
                                </form>
                            </div>
                            <div class="modal-footer"></div>
                        </div><!-- /.modal-content -->
                    </div><!-- /.modal-dialog -->
                </div><!-- /.modal -->
            </div>
        </div>
    <div>
        <!--删除模态框-->
            <div class="modal fade" id="delModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal"
                                    aria-hidden="true">×
                            </button>
                            <h7 class="modal-title" id="myModalLabel">删除记录</h7>
                        </div>
                        <div class="modal-body">
                            <h7>确认删除？</h7>
                            <form th:action="@{/admin/delrecord}" action="/admin/delrecord"  method="post">
                                <input type="hidden" id="del_stuname" name="del_stuname"/>
                                <button type="button" class="btn btn-primary" data-dismiss="modal">取消</button>
                                <button type="submit" class="btn btn-primary" >确认</button>
                            </form>
                        </div>
                        <div class="modal-footer">
                        </div>
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        <!--编辑模态框-->
        <div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"
                                aria-hidden="true">×
                        </button>
                        <h7 class="modal-title" id="myModalLabel">更新记录</h7>
                    </div>
                    <div class="modal-body">
                        <form th:action="@{/admin/editrecord}" action="/admin/editrecord"  method="post">
                            <div class="form-group form-inline">
                                <label for="edit_taskname">课题名称</label>
                                <label id="edit_taskname"></label>
                                <!--<input type="text" name="edit_taskname"id ="edit_taskname" value="" readonly="readonly">-->
                            </div>
                            <div class="form-group form-inline">
                                <label for="edit_stuname">学生姓名</label>
                                <label id="edit_stuname"></label>
                                <!--<input type="text" name="edit_stuname"id ="edit_stuname" value="" readonly="readonly">-->
                                <input type="hidden" id="edit_stuname1" name="edit_stuname1"/>
                            </div>
                            <div class="form-group form-inline">
                                <label for="edit_tutorname">导师姓名</label>
                                <input type="text" name="edit_tutorname" class="form-control" id="edit_tutorname" placeholder="导师姓名">
                                <!--<input type="hidden" id="edit_tutorname1" name="edit_tutorname1"/>-->
                            </div>
                            <div class="form-group form-inline">
                                <label for="edit_state">状态</label>
                                <input type="text" name="edit_state" class="form-control" id="edit_state" placeholder="状态">
                                <!--<input type="hidden" id="edit_state1" name="edit_state1"/>-->
                            </div>
                            <div class="form-group form-inline">
                                <input type="text" name="edit_filename" class="form-control" id="edit_filename" placeholder="文件命名">
                                <button type="button" id="upload_btn1" class="btn btn-primary" >文件上传</button>
                            </div>
                            <button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>
                            <button type="submit" class="btn btn-primary" >提交更改</button>
                        </form>
                    </div>
                    <div class="modal-footer">
                    </div>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
        <center>
    <table id="mainTable" border="1" data-toggle="table" class="bordered">
        <tr>
            <!--<th>ID</th>-->
            <th>课题名称</th>
            <th>学生姓名</th>
            <th>状态</th>
            <th>导师姓名</th>
            <th>编辑</th>
            <th>下载</th>
            <th>删除</th>
        </tr>
        <tr th:each="paperinfo,list:${initdata}">
            <!--<td id="table_id" th:text="${list.size+1}"></td>-->
            <td id="table_taskname" th:text="${paperinfo.taskname}"></td>
            <td id="table_stuname" th:text="${paperinfo.stuname}"></td>
            <td id="table_state" th:text="${paperinfo.state}"></td>
            <td id="table_tutorname" th:text="${paperinfo.tutorname}"></td>
            <td><button id="edit" class='btn btn-link' data-toggle='modal' data-target='#editModal' onclick="edit(this)">编辑</button></td>
            <td><button id="download" class='btn btn-link' data-toggle='modal'data-target='#downModal'>下载</button></td>
            <td><button id="delete" class='btn btn-link' data-toggle='modal' data-target='#delModal' onclick="del(this)">删除</button></td>
        </tr>
    </table>
    </center>
</div>
</div>
</div>
</div>
</div>
<!--底部页脚部分 -->
<div class="footer">
<!--<p class="text-center">
2017 &copy; 浙江工商大学
</p>-->
</div>
</div>

<script type="text/javascript">
//    $(function () { $('#myModal').modal({
//        keyboard: true
//    })});
/*删除记录*/
    function del(obj) {
        var del_stuname = $(obj).parents("tr").find("#table_stuname").text();
        //alert(del_stuname);
        document.getElementById("del_stuname").value= del_stuname;
    }
/*更新记录*/
    function edit(obj){
        var be_taskname = $(obj).parents("tr").find("#table_taskname").text();
        var be_stuname = $(obj).parents("tr").find("#table_stuname").text();
        var be_state = $(obj).parents("tr").find("#table_state").text();
        var be_filename = $(obj).parents("tr").find("#table_filename").text();
        var be_tutorname = $(obj).parents("tr").find("#table_tutorname").text();
        document.getElementById("edit_taskname").innerHTML= be_taskname;
        document.getElementById("edit_stuname").innerHTML= be_stuname;
        document.getElementById("edit_stuname1").value= be_stuname;
        document.getElementById("edit_state").value= be_state;
        document.getElementById("edit_tutorname").value= be_tutorname;
        document.getElementById("edit_filename").innerHTML= be_filename;
    }

/*查询记录*/
    function search(obj){
        var be_taskname = $(obj).parents("tr").find("#table_taskname").text();
        var be_stuname = $(obj).parents("tr").find("#table_stuname").text();
        var be_state = $(obj).parents("tr").find("#table_state").text();
        var be_filename = $(obj).parents("tr").find("#table_filename").text();
        var be_tutorname = $(obj).parents("tr").find("#table_tutorname").text();
        document.getElementById("edit_taskname").innerHTML= be_taskname;
        document.getElementById("edit_stuname").innerHTML= be_stuname;
        document.getElementById("edit_stuname1").value= be_stuname;
        document.getElementById("edit_state").value= be_state;
        document.getElementById("edit_tutorname").value= be_tutorname;
        document.getElementById("edit_filename").innerHTML= be_filename;
    }
</script>
<script th:src="@{/js/bootstrap.min.js}" src="../static/js/bootstrap.min.js"></script>
<script th:src="@{/js/jquery-3.1.1.min.js}" src="../static/js/jquery-3.1.1.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script th:src="@{/js/flat-ui.min.js}" src="../static/js/flat-ui.min.js"></script>
</body>
</html>
